package extensions.android.romarioActivities;

import uclm.extensions.android.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class WaitingConnectionActivity extends Activity
{
	
	@Override
	protected void onCreate(final Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);

		setContentView(R.layout.waiting_server_connection_layout);
		
		
		new Thread(new Runnable() {
			
			@Override
			public void run()
			{
				try
				{
					Thread.sleep(1888);
				} catch (InterruptedException e)
				{
				}
				
				Intent intent = new Intent(WaitingConnectionActivity.this, AdminLobbyActivity.class);
				startActivity(intent);
			}
		}).start();

		/*Thread connectionThread = new Thread(new Runnable() {
			@Override
			public void run()
			{
				try
				{
					Connection.getInstance().connect(getIntent().getExtras().getString("address"));
				} catch (IOException e)
				{
					e.printStackTrace();
					System.out.println("Finalizando actividad.");
					//finishActivity(Activity.RESULT_CANCELED);
					finish();
				}
				
				System.out.println("Finalizando actividad.");
				//finishActivity(ServersActivity.REQUEST_CONNECTION_INFO);
				//finish();
				
				if (Connection.getInstance().getClient().isConnected())
				{
					if (Connection.getInstance().getClient().isLobbyAdministrator())
					{
						Intent intent = new Intent(WaitingConnectionActivity.this, ClientLobbyActivity.class);
						/*Bundle extras = intent.getExtras(); 
						if(extras !=null) {
						    String value = extras.getString(key);
						}
						startActivity(intent);
					}else
					{
						Intent intent = new Intent(WaitingConnectionActivity.this, ClientLobbyActivity.class);
						startActivity(intent);
					}	
				}
			}
		});
		connectionThread.start();*/
	}
	
	
	

}
